<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.7
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ################



$fileid = (int) get('file');


$fData = $DB->fetchRow("SELECT * FROM {$CONFIG->dbprefix}vms_files WHERE id = '{$fileid}'");

if(!is_array($fData) || count($fData)==0){
    JFX::addError('Could not find the file "'.$fileid.'"');
    JFX::redirect($this->adminUrl);
}

if($fData['file_type']!=1){
    JFX::addError('File '.$fileid.' is not a file!');
    JFX::redirect($this->adminUrl);
}

if(!file_exists($this->dirname.'/files/'.$fileid.'.vmsf')){
    JFX::addError('Could not find content for the file '.$this->dirname.'/files/'.$fileid.'.vmsf');
    JFX::redirect($this->adminUrl);
}

while(ob_get_level()>0) ob_end_clean();
header('Content-type: application/text');
header('Content-disposition: attachment; filename="'.$fData['filename'].'"');
readfile($this->dirname.'/files/'.$fileid.'.vmsf');
exit;















